package com.meritdata.cloud.data.standard.table.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.meritdata.cloud.data.base.ResultData;
import com.meritdata.cloud.data.standard.table.service.IDictDirService;
import com.meritdata.cloud.utils.SessionUtils;

/**
 * 字典目录服务
 * 
 * @author Lee
 *
 */
@RestController
@RequestMapping("/dict/dir")
public class DictDirController {

	@Autowired
	private IDictDirService dictDirService;

	@Autowired
	private SessionUtils sessionUtils;

	@RequestMapping("/tree")
	public ResultData tree(HttpServletRequest request) {
		ResultData result = new ResultData();
		result.setData(dictDirService.tree());
		return result;
	}

	@RequestMapping("/create")
	public ResultData create(HttpServletRequest request, @RequestParam String name, @RequestParam Long pid) {
		return dictDirService.create(name, pid, sessionUtils.getCurrentUserId());
	}

	@RequestMapping("/delete")
	public ResultData delete(HttpServletRequest request, @RequestParam long id) {
		return dictDirService.delete(id);
	}

}
